home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / newtk200.zip / NEWTRACK.HPP < prev    next >
C/C++ Source or Header  |  1993-03-11  |  5KB  |  134 lines

  1. // @(#) %M% V%I% %H%
  2. //
  3. // File name
  4. // -------------
  5. // NEWTRACK.HPP
  6. //
  7. // (c) Cavendish Software Ltd 1991, 1992
  8. //
  9. // Document References
  10. // -------------------
  11. // This is a general purpose module, and as such has no document references
  12. //
  13. // File Description
  14. // ----------------
  15. // Newtrack v2.0/Windows.  This version of NewTrack supports windows and DLLs.
  16. //
  17.  
  18.  
  19. #ifndef NEWTRACK_HPP
  20. #define NEWTRACK_HPP
  21.  
  22.  
  23. // PREPROCESSOR SYMBOL DEFINITIONS -- Complete Exclusion of NewTrack
  24. #if (!defined(USE_NEWTRACK)) || (USE_NEWTRACK)
  25.  
  26.  
  27. // PREPROCESSOR SYMBOL DEFINITIONS -- DLL/Exports
  28. #ifdef __DLL__
  29. #define NT_EXPORT _export far
  30. #else
  31. #define NT_EXPORT
  32. #endif
  33.  
  34.  
  35. // PREPROCESSOR SYMBOL DEFINITIONS
  36. // Try to get the caller's address off the stack.  Assuming that this
  37. //    is compiled in Large model with parameters passed on the stack,
  38. //    the callers return address starts at BP + 2 + argument_size.
  39. //
  40. // Register setup:
  41. //    DS == SS
  42. //
  43. #define NT_GETCALLER(n, seg, off)                                                    \
  44.     asm push ax;                                                                       \
  45.                                                                                     \
  46.     asm mov ax, [bp + 2 + n];                                                       \
  47.     asm mov seg, ax;                                                                \
  48.                                                                                     \
  49.     asm mov ax, [bp + 0 + n];                                                       \
  50.     asm mov off, ax;                                                                \
  51.                                                                                     \
  52.     asm pop ax;
  53. /*
  54. #define NT_GETCALLER(n)                                                                \
  55.     unsigned    coff;                                                               \
  56.     unsigned    cseg;                                                               \
  57.     unsigned    oldax;                                                              \
  58.                                                                                     \
  59.     asm mov oldax, ax;                                                               \
  60.                                                                                     \
  61.     asm mov ax, [bp + 2 + n];                                                       \
  62.     asm mov cseg, ax;                                                               \
  63.                                                                                     \
  64.     asm mov ax, [bp + 0 + n];                                                       \
  65.     asm mov coff, ax;                                                               \
  66.                                                                                     \
  67.     asm mov ax, oldax;
  68. */
  69.  
  70.  
  71. // PREPROCESSOR SYMBOL DEFINITIONS -- Over/Under run checking
  72. #define NT_PRE_TEXT            "PrePrePrePre"
  73. #define NT_PRE_SIZE            strlen(NT_PRE_TEXT)
  74. #define NT_POST_TEXT        "PostPostPost"
  75. #define NT_POST_SIZE        strlen(NT_POST_TEXT)
  76.  
  77.  
  78. // PREPROCESSOR SYMBOL DEFINITIONS -- Fill Characters
  79. #define NT_NEWFILL            '#'
  80. #define NT_DELFILL            (0xff)
  81.  
  82.  
  83. // PREPROCESSOR SYMBOL DEFINITIONS -- Macros to turn NewTrack on & off
  84. #define NEWTRACK_ON()        __newtrack = 1
  85. #define NEWTRACK_OFF()        __newtrack = 0
  86. #define NEWTRACK_PUSH()        int __save__newtrack = __newtrack;
  87. #define NEWTRACK_POP()        __newtrack = __save__newtrack;
  88.  
  89.  
  90. // TYPE DEFINITIONS
  91. typedef unsigned char huge    *NT_PTR;
  92. typedef unsigned long        NT_SIZE;
  93. typedef void far *            TRK_CALLER;
  94.  
  95.  
  96. // EXTERNAL VARIABLES -- Turns NewTrack on & off in NEWTRACK.CPP
  97. extern int _far __newtrack;
  98.  
  99.  
  100. // FUNCTION PROTOTYPES
  101. #ifdef __cplusplus
  102. extern "C"
  103. {
  104. #endif
  105. void            NT_EXPORT _far _pascal NT_Initialise(void);
  106. unsigned long    NT_EXPORT _far _pascal NT_Terminate(void);
  107. unsigned long    NT_EXPORT _far _pascal NT_NAllocs(void);
  108. NT_PTR            NT_EXPORT _far _pascal NT_New(void far *_p, NT_SIZE size, TRK_CALLER caller);
  109. void far *        NT_EXPORT _far _pascal NT_Delete(NT_PTR p);
  110. NT_SIZE            NT_EXPORT _far _pascal NT_NewSize(unsigned long size);
  111. void far *                  NT_AllocMem(unsigned long size, void far *caller);
  112. #ifdef __cplusplus
  113. };
  114. #endif
  115.  
  116. #else // !def(USE_NEWTRACK) || USE_NEWTRACK
  117.  
  118.  
  119. // PREPROCESSOR SYMBOL DEFINITIONS -- Fake NewTrack to the compiler
  120. #define NEWTRACK_ON()
  121. #define NEWTRACK_OFF()
  122. #define NEWTRACK_PUSH()
  123. #define NEWTRACK_POP()
  124. #define NT_Initialise(void)
  125. #define NT_Terminate(void)        0
  126. #define NT_NAllocs(void)        0
  127.  
  128.  
  129. #endif // !def(USE_NEWTRACK) || USE_NEWTRACK
  130.  
  131. #endif // !def(NEWTRACK_HPP)
  132.  
  133.  
  134.